package view.userinteface;
import java.awt.BorderLayout;

import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.WindowConstants;

import beans.BeanCliente;

import view.controller.ControllerPrincipal;




/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class JInternalFrameAltaCliente extends javax.swing.JInternalFrame {

	private JButton btnAceptar;
	private JTextField jTextField1;
	private JLabel jLabel1;
	private JTextField txtContacto;
	private JLabel lblContacto;
	private JTextField txtDescuentos;
	private JLabel lblDescuentos;
	private JButton btnCancelar;
	private JTextField txtCUIT;
	private JLabel lblCUIT;
	private static JInternalFrameAltaCliente instancia;

	/**
	* Auto-generated main method to display this 
	* JInternalFrame inside a new JFrame.
	*/
		
	public static JInternalFrameAltaCliente getInstancia(){
		if (instancia==null){
			instancia = new JInternalFrameAltaCliente();
		}
		return instancia;
	}
	
	public JInternalFrameAltaCliente() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			this.setPreferredSize(new java.awt.Dimension(392, 293));
			this.setBounds(0, 0, 392, 293);
			setVisible(true);
			this.setTitle("Alta Cliente");
			getContentPane().setLayout(null);
			this.setSize(400, 400);
			{
				btnAceptar = new JButton();
				getContentPane().add(btnAceptar, "Center");
				btnAceptar.setText("Aceptar");
				btnAceptar.setBounds(70, 207, 98, 26);
				btnAceptar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						ControllerPrincipal controllerPrincipal = new ControllerPrincipal();
						BeanCliente dtoCliente = new BeanCliente();
						dtoCliente.setCuit(Integer.parseInt(txtCUIT.getText()));
						dtoCliente.setContacto(txtContacto.getText());
						dtoCliente.setDescuentoAsociado(txtDescuentos.getText());
						boolean result = controllerPrincipal.getInstancia().altaCliente(dtoCliente);
						if (result)
							JOptionPane.showMessageDialog(JInternalFrameAltaCliente.getInstancia(),"Grabe ok :D");
						else
							JOptionPane.showMessageDialog(JInternalFrameAltaCliente.getInstancia().getInstancia(),"Grabe MAL :(.");
							
						}
					}
				);
			}
			{
				btnCancelar = new JButton();
				getContentPane().add(btnCancelar);
				btnCancelar.setText("Cancelar");
				btnCancelar.setBounds(206, 207, 107, 26);
				btnCancelar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						dispose();
					}
				});
			}
			{
				lblCUIT = new JLabel();
				getContentPane().add(lblCUIT);
				lblCUIT.setText("CUIT: ");
				lblCUIT.setBounds(33, 33, 132, 14);
			}
			{
				txtCUIT = new JTextField();
				getContentPane().add(txtCUIT);
				txtCUIT.setBounds(178, 30, 166, 21);
			}
			{
				lblDescuentos = new JLabel();
				getContentPane().add(lblDescuentos);
				lblDescuentos.setText("Descuentos: ");
				lblDescuentos.setBounds(33, 135, 132, 14);
			}
			{
				txtDescuentos = new JTextField();
				getContentPane().add(txtDescuentos);
				txtDescuentos.setBounds(178, 132, 166, 21);
			}
			{
				lblContacto = new JLabel();
				getContentPane().add(lblContacto);
				lblContacto.setText("Contacto:");
				lblContacto.setBounds(33, 66, 132, 14);
			}
			{
				txtContacto = new JTextField();
				getContentPane().add(txtContacto);
				txtContacto.setBounds(178, 63, 166, 21);
			}
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1);
				jLabel1.setText("Condiciones Venta: ");
				jLabel1.setBounds(33, 99, 132, 14);
			}
			{
				jTextField1 = new JTextField();
				getContentPane().add(jTextField1);
				jTextField1.setBounds(178, 96, 166, 21);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
